﻿using DataFileApplication_WPF.Commands;
using DataFileApplication_WPF.Models;
using DataFileApplication_WPF.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DataFileApplication_WPF.Views
{
    /// <summary>
    /// EditValueListView.xaml 的交互逻辑
    /// </summary>
    public partial class EditValueListView : Window
    {
        EditValueListViewModel editValueListViewModel;
        public EditValueListView(DataGridItemStruct dataGridItemStruct)
        {
            InitializeComponent();
            //editValueListViewModel = new EditValueListViewModel(dataGridItemStruct);

            this.DataContext = new EditValueListViewModel(dataGridItemStruct);
        }

        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            //if (this.DataContext is EditValueListViewModel editValueListViewModel)
            //{
            //    //清除原始集合内容
            //    editValueListViewModel.OriDataGridItemStruct.ValueList.Clear();

            //    //依次将内容添加到oriDataGridItemStruct的ValueList中,这样才能触发集合内容的变化事件，直接集合赋值不会触发变化事件
            //    for (int i = 0; i < editValueListViewModel.DataGridItemStructForEdit.ValueList.Count; i++)
            //    {
            //        editValueListViewModel.OriDataGridItemStruct.ValueList.Add(editValueListViewModel.DataGridItemStructForEdit.ValueList[i]);
            //    }
            //}
            this.DialogResult = true;
            this.Close();
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
    }
}
